home *** CD-ROM | disk | FTP | other *** search
- # Source Generated with Decompyle++
- # File: in.pyo (Python 2.4)
-
- import pprint
- import test.test_support as test
- import unittest
-
- try:
- uni = unicode
- except NameError:
-
- def uni(x):
- return x
-
-
-
- class list2(list):
- pass
-
-
- class list3(list):
-
- def __repr__(self):
- return list.__repr__(self)
-
-
-
- class tuple2(tuple):
- pass
-
-
- class tuple3(tuple):
-
- def __repr__(self):
- return tuple.__repr__(self)
-
-
-
- class dict2(dict):
- pass
-
-
- class dict3(dict):
-
- def __repr__(self):
- return dict.__repr__(self)
-
-
-
- class QueryTestCase(unittest.TestCase):
-
- def setUp(self):
- self.a = range(100)
- self.b = range(200)
- self.a[-12] = self.b
-
-
- def test_basic(self):
- verify = self.assert_
- pp = pprint.PrettyPrinter()
- for safe in (2, 2.0, (0.0+2.0j), 'abc', [
- 3], (2, 2), {
- 3: 3 }, uni('yaddayadda'), self.a, self.b):
- verify(not pprint.isrecursive(safe), 'expected not isrecursive for %r' % (safe,))
- verify(pprint.isreadable(safe), 'expected isreadable for %r' % (safe,))
- verify(not pp.isrecursive(safe), 'expected not isrecursive for %r' % (safe,))
- verify(pp.isreadable(safe), 'expected isreadable for %r' % (safe,))
-
-
-
- def test_knotted(self):
- self.b[67] = self.a
- self.d = { }
- self.d[0] = self.d[1] = self.d[2] = self.d
- verify = self.assert_
- pp = pprint.PrettyPrinter()
- for icky in (self.a, self.b, self.d, (self.d, self.d)):
- verify(pprint.isrecursive(icky), 'expected isrecursive')
- verify(not pprint.isreadable(icky), 'expected not isreadable')
- verify(pp.isrecursive(icky), 'expected isrecursive')
- verify(not pp.isreadable(icky), 'expected not isreadable')
-
- self.d.clear()
- del self.a[:]
- del self.b[:]
- for safe in (self.a, self.b, self.d, (self.d, self.d)):
- verify(not pprint.isrecursive(safe), 'expected not isrecursive for %r' % (safe,))
- verify(pprint.isreadable(safe), 'expected isreadable for %r' % (safe,))
- verify(not pp.isrecursive(safe), 'expected not isrecursive for %r' % (safe,))
- verify(pp.isreadable(safe), 'expected isreadable for %r' % (safe,))
-
-
-
- def test_unreadable(self):
- verify = self.assert_
- pp = pprint.PrettyPrinter()
- for unreadable in (type(3), pprint, pprint.isrecursive):
- verify(not pprint.isrecursive(unreadable), 'expected not isrecursive for %r' % (unreadable,))
- verify(not pprint.isreadable(unreadable), 'expected not isreadable for %r' % (unreadable,))
- verify(not pp.isrecursive(unreadable), 'expected not isrecursive for %r' % (unreadable,))
- verify(not pp.isreadable(unreadable), 'expected not isreadable for %r' % (unreadable,))
-
-
-
- def test_same_as_repr(self):
- verify = self.assert_
- for x in range(100):
- pass
-
-
-
- def test_basic_line_wrap(self):
- o = {
- 'RPM_cal': 0,
- 'RPM_cal2': 48059,
- 'Speed_cal': 0,
- 'controldesk_runtime_us': 0,
- 'main_code_runtime_us': 0,
- 'read_io_runtime_us': 0,
- 'write_io_runtime_us': 43690 }
- exp = "{'RPM_cal': 0,\n 'RPM_cal2': 48059,\n 'Speed_cal': 0,\n 'controldesk_runtime_us': 0,\n 'main_code_runtime_us': 0,\n 'read_io_runtime_us': 0,\n 'write_io_runtime_us': 43690}"
- for type in [
- dict,
- dict2]:
- self.assertEqual(pprint.pformat(type(o)), exp)
-
- o = range(100)
- exp = '[%s]' % ',\n '.join(map(str, o))
- for type in [
- list,
- list2]:
- self.assertEqual(pprint.pformat(type(o)), exp)
-
- o = tuple(range(100))
- exp = '(%s)' % ',\n '.join(map(str, o))
- for type in [
- tuple,
- tuple2]:
- self.assertEqual(pprint.pformat(type(o)), exp)
-
- o = range(100)
- exp = '[ %s]' % ',\n '.join(map(str, o))
- for type in [
- list,
- list2]:
- self.assertEqual(pprint.pformat(type(o), indent = 4), exp)
-
-
-
- def test_subclassing(self):
- o = {
- 'names with spaces': 'should be presented using repr()',
- 'others.should.not.be': 'like.this' }
- exp = "{'names with spaces': 'should be presented using repr()',\n others.should.not.be: like.this}"
- self.assertEqual(DottedPrettyPrinter().pformat(o), exp)
-
-
-
- class DottedPrettyPrinter(pprint.PrettyPrinter):
-
- def format(self, object, context, maxlevels, level):
- if isinstance(object, str):
- if ' ' in object:
- return (repr(object), 1, 0)
- else:
- return (object, 0, 0)
- else:
- return pprint.PrettyPrinter.format(self, object, context, maxlevels, level)
-
-
-
- def test_main():
- test.test_support.run_unittest(QueryTestCase)
-
- if __name__ == '__main__':
- test_main()
-
-